package lz.controls.core
{
	import com.common.utils.Reflection;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.MouseEvent;
	
	import lz.controls.BaseWindow;
	import lz.controls.LButton;

	/**
	 * 带标题窗口
	 * @author lxh
	 * 
	 */	
	public class TitleWindow extends BaseWindow
	{
		/**
		 *关闭按钮 
		 */		
		protected var closeBtn :SimpleButton;
		
		public function TitleWindow()
		{
			
		}
		/**
		 *config ui 
		 * 
		 */		
		protected function configBgUI():void
		{
			super.configUI();
		}
		/**
		 *设置背景和按钮  
		 * @param $bgName
		 * 
		 */
		public function setBg($bgName:String = "skin.WindowBg"):void
		{
			windowBg = Reflection.createInstance($bgName);
			windowBg.cacheAsBitmap = true;
			windowBg.width = bgWidth;
			windowBg.height = bgHeight;
			this.addChild(windowBg);
		}
		/**
		 *设置关闭按钮 
		 * 
		 */
		public function setCloseBtn(clBtn:* = null):void
		{
			if(clBtn == null)
			{
				closeBtn = Reflection.createInstance("com.liangzhong.ui.closeBtn");
				_symbolSkin.addChild(closeBtn);
				closeBtn.x = _symbolSkin.width - closeBtn.width ;
				closeBtn.y = 3;
			}
			else
			{
				closeBtn = clBtn;
			}
			closeBtn.addEventListener(MouseEvent.CLICK,onCloseHandler);
		}
		/**
		 * 关闭按钮响应
		 * @param e
		 * 
		 */		
		protected function onCloseHandler(e :MouseEvent):void
		{
			if(this.parent)
			{
				this.parent.removeChild(this);
			}
		}
	}
}